package com.example.yls.demoa;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;

/**
 * Created by yls on 2019/5/13.
 */

public class circleProgree extends View {
    public int getProgress() {
        return progress;
    }

    Paint paint=new Paint();

    public void setProgress(int progress) {
        this.progress = progress;
        invalidate();
    }

    private  int progress=88;
    public circleProgree(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        paint.setDither(true);
        paint.setAntiAlias(true);
        paint.setStrokeWidth(20);

    }

    @Override
    protected void onDraw(Canvas canvas) {
        paint.setColor(Color.RED);
        canvas.drawCircle(300,300,300,paint);


        paint.setColor(Color.GREEN);
        paint.setStrokeWidth(15);
        canvas.drawArc(110,150,610,650,270,360*progress/100,false,paint);




        paint.setColor(Color.BLUE);
        paint.setStyle(Paint.Style.FILL);
        paint.setTextSize(30);
        paint.setStrokeWidth(20);
        canvas.drawText("运动消耗",150,150,paint);
        canvas.drawText(""+progress+"%",150,180,paint);

        super.onDraw(canvas);
    }
}
